<template>
  <div>
    <el-table :data="listTableData" tooltip-effect="dark" style="width: 100%">
      <el-table-column prop="name" label="姓名" width="120"> </el-table-column>
      <el-table-column prop="address" label="地址" show-overflow-tooltip>
      </el-table-column>
      <el-table-column property="address" label="操作">
        <template slot-scope="scope">
          <el-button
            @click="handleOpenDialog(scope.row)"
            type="text"
            size="small"
            >修改</el-button
          >
        </template>
      </el-table-column>
    </el-table>
    <my-dialog v-model="dialogTableVisible" :formData="formData"></my-dialog>
  </div>
</template>

<script>
import myDialog from "./dialog.vue";
export default {
  components: {
    myDialog,
  },
  data() {
    return {
      listTableData: [
        {
          name: "王小虎",
          address: "上海市普陀区金沙江路 1518 弄",
        },
        {
          name: "王小虎",
          address: "上海市普陀区金沙江路 1517 弄",
        },
        {
          name: "王小虎",
          address: "上海市普陀区金沙江路 1519 弄",
        },
        {
          name: "王小虎",
          address: "上海市普陀区金沙江路 1516 弄",
        },
      ],
      formData: {},
      dialogTableVisible: false,
    };
  },

  methods: {
    handleOpenDialog(row) {
      this.dialogTableVisible = true;
      this.formData = JSON.parse(JSON.stringify(row));
    },
  },
};
</script>
